package com.yunhe.energy.client;

import com.yunhe.energy.client.fallback.MeasHistoryFallbackFactory;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.data.MeasurePointMap;
import com.yunhe.common.model.data.Measurement;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 量测历史数据Feign客户端
 * @author liuronglei
 */
@ApiIgnore
@FeignClient(value = "yh-meas-history", fallbackFactory = MeasHistoryFallbackFactory.class)
@Component
public interface MeasHistoryClient {


    /**
     * 根据条件获得量测列表
     * @param pointNumber 点号
     * @param dtime 时间范围
     */
     @RequestMapping(value = "/measurements", method = RequestMethod.GET)
     ResponseEntity<ResultObject<List<Measurement>>> getMeasurements(@RequestParam("pointNumber") Long pointNumber,
                                                                     @RequestParam("dtime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") List<Date> dtime,
                                                                     @RequestParam Map<String, Object> pageParam);

    /**
     * 根据点号获得点号与最后一次值不同的前一次的值
     * @param pointNumber 点号
     */
    @RequestMapping(value = "/measurements/preValue", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Double>> getPreValue(@RequestParam("pointNumber") Long pointNumber);
}
